<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:choose>
<c:when test="${not empty onGoingCourseRounds}">
  <c:forEach var="courseRound" items="${onGoingCourseRounds}">
   <li class="course">
     <a href="${ctx.host}/profile/courses/${courseRound.id}" class="item-link item-content">
       <div class="item-media"><img src="${cloud.prod}/${courseRound.course.cover}" style='width: 4rem;'></div>
       <div class="item-inner">
         <div class="item-title-row">
           <div class="item-title">${courseRound.course.name}</div>
         </div>
         <div class="item-text" style="height: auto;">
          <c:choose>
            <c:when test="${courseRound.courseType.year}">
              <c:if test="${courseRound.coach == null}">
                暂未给您分配教练，请耐心等待~<br>
              </c:if>
              <c:if test="${courseRound.coach != null}">
                主教练：${courseRound.coach.name}<br>
              </c:if>
              <c:if test="${courseRound.courseStatus.ready || courseRound.courseStatus.activate}">
                有效期至：<fmt:formatDate value="${courseRound.effectiveEnd}" pattern="yyyy-MM-dd"/><br>
              </c:if>
              <c:if test="${courseRound.courseStatus.hold}">
                有效期至：<fmt:formatDate value="${courseRound.effectiveEndTime}" pattern="yyyy-MM-dd"/><br>
              </c:if>
              <c:if test="${courseRound.effectiveEnd == null && courseRound.courseStatus.prepare}">
                您还未排课，点击进入详情去排课哦~<br>
              </c:if>
              已完成<span class="color-dark">&nbsp;${courseRound.finished}&nbsp;</span>课时。<span class="color-blue">${courseRound.courseStatus.hold ? '冻结中' : courseRound.courseStatus.activate ? '待激活' : ''}</span>
            </c:when>
            <c:when test="${courseRound.courseType.individual}">
              ${courseRound.site.name}<br>
              <c:if test="${courseRound.coach == null}">
                暂未给您分配教练，请耐心等待~<br>
              </c:if>
              <c:if test="${courseRound.coach != null}">
                主教练：${courseRound.coach.name}<br>
              </c:if>
              <c:if test="${courseRound.coach != null && courseRound.courseStatus.prepare}">
                您还未排课，点击进入详情去排课哦~<br>
              </c:if>
              <c:if test="${courseRound.courseStatus.ready || courseRound.courseStatus.hold || courseRound.courseStatus.activate}">
                有效期至：<fmt:formatDate value="${courseRound.effectiveEnd}" pattern="yyyy-MM-dd"/><br>
              </c:if>
               已上<span class="color-dark">&nbsp;${courseRound.finished}&nbsp;</span>节课，
              <c:if test="${courseRound.courseStatus.ready || courseRound.courseStatus.prepare}">
                剩余&nbsp;<span class="color-dark">${courseRound.attrs['course_amount'].value == null ? (courseRound.course.hours - courseRound.finished) : (courseRound.attrs['course_amount'].value - courseRound.finished)}</span>&nbsp;节课。
              </c:if>
              <c:if test="${courseRound.courseStatus.hold}">
                <span class="color-blue">冻结中</span>
              </c:if>
              <c:if test="${courseRound.courseStatus.activate}">
                <span class="color-blue">待激活</span>
              </c:if>
            </c:when>
            <c:when test="${courseRound.courseType.group}">
              <c:if test="${courseRound.code == null}">
                 您还未入团，请耐心等待~<br>
              </c:if>
              <c:if test="${courseRound.code != null}">
                团课编号：${courseRound.groupAttr.description}，操房：${courseRound.groupAttr.gym}<br>
              </c:if>
              已上<span class="color-dark">&nbsp;${courseRound.finished}&nbsp;</span>节课，剩余&nbsp;<span class="color-dark">${courseRound.attrs['course_amount'].value == null ? (courseRound.course.hours - courseRound.finished) : (courseRound.attrs['course_amount'].value - courseRound.finished)}</span>&nbsp;节课。
            </c:when>
            <c:when test="${courseRound.courseType.online}">
              ${courseRound.product.name}
            </c:when>
          </c:choose>
         </div>
       </div>
     </a>
   </li>
  </c:forEach>
</c:when>
  <c:otherwise>
    <p style="text-align: center; font-size: .8rem;">暂无在营课程</p>
  </c:otherwise>
</c:choose>